package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.FaultCustForm;
import com.ruoyi.system.domain.WorkCustomer;
import com.ruoyi.system.domain.WorkForm;
import com.ruoyi.system.service.IWorkCustomerService;
import com.ruoyi.system.service.IWorkFormService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户Controller
 *
 * @author ruoyi
 * @date 2020-04-20
 */
@Controller
@RequestMapping("/system/check")
public class workCheckController  extends BaseController {
    private String prefix = "system/check";

    @Autowired
    private IWorkCustomerService workCustomerService;

    @Autowired
    private IWorkFormService workFormService;

    //@RequiresPermissions("system:check:view")
    @GetMapping()
    public String customer()
    {
        return prefix + "/check";
    }

    /**
     * 查询用户列表
     */
    //@RequiresPermissions("system:check:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WorkForm workForm)
    {
        startPage();
        String loginName = "admin";
        List<FaultCustForm> list =workFormService.selectWorkCheckList(workForm,loginName);
        return getDataTable(list);
    }

    /**
     * 审核
     */
    //@RequiresPermissions("system:form:edit")
    @Log(title = "审核", businessType = BusinessType.UPDATE)
    @PostMapping("/checkOk/{id}/{checkId}")
    @ResponseBody
    public AjaxResult editSave(@PathVariable("id") Long id,@PathVariable("checkId") Long checkId) {
        return toAjax(workFormService.updateWorkFormBycheckOk(id,checkId));
    }
}
